package com.siwei.mes.service.laboratory.factory.concrete;

import com.siwei.mes.enums.TestProjectEnum;
import com.siwei.mes.service.laboratory.factory.concrete.service.ConcreteKsdjFactory;
import com.siwei.mes.service.laboratory.factory.concrete.service.ConcreteKyqdFactory;
import com.siwei.mes.service.laboratory.factory.concrete.service.ConcreteKzqdFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 混凝土工厂选择器
 *
 * @Description: 混凝土工厂选择器
 * @Version: 1.0
 * @author: mlchen
 * @date: 2025/3/28 22:06
 */
@Service
public class ConcreteLaboratoryFactorySelector {
    private static final Logger log = LoggerFactory.getLogger("laboratory");

    private static final Map<String, ConcreteLaboratoryFactory> FACTORY_MAP = new HashMap<>();
    @Resource
    private ConcreteKyqdFactory concreteKyqdFactory;
    @Resource
    private ConcreteKsdjFactory concreteKsdjFactory;
    @Resource
    private ConcreteKzqdFactory concreteKzqdFactory;

    @PostConstruct
    public void init() {
        FACTORY_MAP.put(TestProjectEnum.CONCRETE_PARAM_KYQD.getCode(), concreteKyqdFactory);
        FACTORY_MAP.put(TestProjectEnum.CONCRETE_PARAM_KSDJ.getCode(), concreteKsdjFactory);
        FACTORY_MAP.put(TestProjectEnum.CONCRETE_PARAM_KZQD.getCode(), concreteKzqdFactory);
        log.info("初始化【协会混凝土】工厂选择器完成！初始化个数：【{}】", FACTORY_MAP.size());
    }

    public static ConcreteLaboratoryFactory getFactory(String testProjectCode) {
        return FACTORY_MAP.get(testProjectCode);
    }
}
